<?php

use yii\db\Migration;
use yii\db\Schema;

/**
 * Class m180329_011102_CREATE_DB_MEMBER
 */
class m180329_011102_CREATE_DB_MEMBER extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

        // 成员
        $this->createTable('member', [
            "id" =>         Schema::TYPE_PK,
            "phone" =>      Schema::TYPE_STRING.    "(64) NOT NULL COMMENT '电话'",
            "passwd" =>     Schema::TYPE_STRING.    "(64) NULL COMMENT '密码'",
            "name" =>       Schema::TYPE_STRING.    "(64) NULL COMMENT '姓名'",
            "role" =>       Schema::TYPE_INTEGER.   "(1) DEFAULT '1' COMMENT '角色'",
            "login_time" => Schema::TYPE_DATETIME. " NULL COMMENT '最后次登录时间'",
            "desc" =>       Schema::TYPE_STRING.    "(522) NULL COMMENT '描述'",
            "status" =>     Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "user_id" =>    Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '管理员编号'",
            "created_at" => Schema::TYPE_DATETIME. " NULL",
            "updated_at" => Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m180329_011102_CREATE_DB_MEMBER cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180329_011102_CREATE_DB_MEMBER cannot be reverted.\n";

        return false;
    }
    */
}
